# 使用预封装好的load_summarize_chain
from langchain.chains.summarize import load_summarize_chain
from langchain_community.chat_models import ChatOpenAI
from langchain_community.document_loaders import PyPDFLoader
import __init__

loader = PyPDFLoader("../kecheng源码/loader.pdf")
docs = loader.load()
llm = ChatOpenAI(
    temperature=0,
    model="gpt-4-1106-preview",
)
chain = load_summarize_chain(
    llm=llm,
    chain_type="stuff",
    verbose=True,
)

print(chain.run(docs))
